﻿/*
Documentation link for wizard
Includes: Ajax Call, Validations, highlight error steps, message inside wizard
http://techlaboratory.net/smartwizard/documentation
*/

$(document).ready(function () {
    
    try
    {
    // Initialize Smart Wizard
    $('#wizard').smartWizard({ onFinish: WizardFinish })  // triggers when Finish button is clicked);
    
    }catch(err){}

});

function WizardFinish() {
    window.location = "Default.aspx"
}


/*
Custom Functions

*/

function AddClass() {
	
	var strOptions="<a class='btn_no_text btn ui-state-default ui-corner-all tooltip' title='Edit this Class' href='#'><span class='ui-icon ui-icon-wrench'></span></a></a><a class='btn_no_text btn ui-state-default ui-corner-all tooltip' title='Delete this Class' href='#'><span class='ui-icon ui-icon-circle-close'></span></a>";
	var ClassName=$("#txtClassName").val();
	
    $("#ClassList tbody").append("<tr>  <td>"+ClassName+"</td> <td>"+strOptions+"</td></tr>");
	$(".stepContainer").removeAttr("style");
}


function SubjectChange() {
    if (document.getElementById("SelectedSubject").value == "New") {
        $("#AddSubjectTr").removeAttr("style");
    }
    else {
        $("#AddSubjectTr").css("display", "none");

    }
    $(".stepContainer").removeAttr("style");
}


function AssignSubjectsToClass() {
	
	var strOptions="<a class='btn_no_text btn ui-state-default ui-corner-all tooltip' title='Edit this Class' href='#'><span class='ui-icon ui-icon-wrench'></span></a></a><a class='btn_no_text btn ui-state-default ui-corner-all tooltip' title='Delete this Class' href='#'><span class='ui-icon ui-icon-circle-close'></span></a>";
	var SubjectName="";
	
	
	if($("#SelectedSubject").val()=="New")
	{
		SubjectName=$("#txtNewSubject").val();
		//Append New one to the Selection Control
			$("#SelectedSubject").append("<option>"+SubjectName+"</option>");
		}
		else
		{SubjectName=$("#SelectedSubject").val();
			}
	
	
    $("#AssignedSubjects tbody").append("<tr>  <td>"+SubjectName+"</td> <td>"+strOptions+"</td></tr>");
	$(".stepContainer").removeAttr("style");
}